<script type="text/javascript">
	function onlyNumbers(evt) 
	{
		evt = (evt) ? evt : window.event
		var charCode = (evt.which) ? evt.which : evt.keyCode
		if (charCode > 31 && (charCode < 48 || charCode > 57)) {
			//status = "This field accepts numbers only."
			alert("Harus di Isi Angka");
			return false
		}
		//status = ""
		return true 	
	}
</script>
<style type="text/css">
body,td,th {
	font-family: Arial, Helvetica, sans-serif;
	font-size: 14px;
}
</style>

<form method="post" name="frmSearch" action="<?php echo site_url('mstrstockcontroller');?>">
    <table width="100%" cellpadding="3" cellspacing="0" border="1">
        <tr>
            <td width="130"><strong>Pilih Search</strong></td>
            <td width="21" align="center" ><strong>:</strong></td>
            <td width="836" colspan="3">
                <select name="kdbrgview">
                    <option value="0">Pilih</option>
                    <option value="1">Kode Stock</option>
                    <option value="2">Nama Barang</option>
                    <option value="3">Nama Suplier</option>
                </select> &nbsp;|&nbsp;<input type="text"  name="brgview" id="brgview" size="50" />&nbsp;|&nbsp;<input type="submit" name="btnview" value="Search">
            </td>
		</tr>
    </table>
</form>
<br />
<form method="post" name="frmSave" action="<?php echo site_url('mstrstockcontroller/tambahmstrstock');?>">
    <table width="100%" cellpadding="3" cellspacing="0" border="1">
    	<tr style="background-color:#FFF; color:#000000;" align="center">
        	<td colspan="3" height="25"><strong>INPUT DAFTAR JUMLAH STOCK</strong></td>
    	</tr>
        <tr >
        	<td colspan="3" height="25">&nbsp;</td>
    	</tr>
        <tr>
            <td width="132"><strong>Kode Stock</strong></td>
            <td width="23" align="center"><strong>:</strong></td>
            <td width="832" colspan="3"><input type="text"  name="kdstock" id="kdstock" maxlength="12" size="25" value="{kodestock}" readonly="readonly"/></td>
        </tr>
        <tr>
            <td width="132"><strong>Nama Supplier</strong></td>
            <td width="23" align="center"><strong>:</strong></td>
            <td width="832" colspan="3">
            	<select name="kdsupp">
                    <?php 
						$count = count($mastersupp);
                    	foreach($mastersupp as $comboInd)
						{
                    ?>
                    	<option value="<?php echo $comboInd->Kodesupplier?>"><?php echo $comboInd->suppliername;?></option>
                    <?php }?>
                </select>
			</td>
        </tr>
        <tr>
            <td width="132"><strong>Nama Barang</strong></td>
            <td width="23" align="center"><strong>:</strong></td>
            <td width="832" colspan="3">
            	<select name="kdbrng" >
                    <?php 
						$count = count($masterbrg);
                    	foreach($masterbrg as $comboInd)
						{
                    ?>
                    	<option value="<?php echo $comboInd->KodeDetailBarang?>"><?php echo $comboInd->Productname;?></option>
                    <?php }?>
                </select>
			</td>
        </tr>
        <!--<tr>
            <td width="98">Stock Awal</td>
            <td width="18">:</td>
            <td ><input type="text"  name="stkawal" id="stkawal" maxlength="11" size="25" /></td>
        </tr>-->
        <tr>
            <td width="132"><strong>Jumlah Stock</strong></td>
            <td width="23" align="center"><strong>:</strong></td>
            <td ><input type="text"  name="stkakhir" id="stkakhir" size="25" maxlength="11" onkeypress="return onlyNumbers(event);"/></td>
        </tr>
        <tr>
            <td colspan="3" align="center"><input type="submit" value="Save" name="btnSave" >&nbsp;<input type="button" name="btnClose" value="Back" class="btn" onclick="javascript:window.location='<?php echo site_url('menuhomecontroller'); ?>';" /></td>
        </tr>
    </table>
</form>
<br />
<br />
<div class="cleaner_h10"></div>
<table border="1" cellpadding="3" cellspacing="0" width="100%" style=" border-collapse: collapse;" class="record" bordercolor="#CCCCCC">
    <tr style="background-color:#FFF; color:#000000;" align="center">
        <td colspan="7" height="25"><strong>LIST JUMLAH STOCK</strong></td>
    </tr>
    <tr style="background-color:#333; color:#FFF;" align="center">
    	<td>Kode Stock</td>
        <td>Nama Supplier</td>
        <td>Nama Barang</td>
        <!--<td>Stock Awal</td>-->
        <td>Jumlah Stock</td>
        <?php
			if($this->session->userdata('grade') == 0)
			{
		?>
        <td>&nbsp;</td>
        <?php } ?>
    </tr>
	<?php if(count($mstrstock)>0){ ?>
        {mstrstock}
            <tr class="cellDefault">
                <td align="center" >{KodeStok}</td>
                <td align="center">{suppliername}</td>
                <td align="center">{Productname}</td>
                <!--<td>{StockAwal}</td>-->
                <td align="center">{StockAkhir}</td> 
				<?php
                if($this->session->userdata('grade') == 0)
				{
				?>
                <td align="center">
                	<button onclick="javascript:window.location='<?php echo site_url('mstrstockcontroller/ubahmstrstock');?>/{KodeStok}';" id="edit">Edit</button>
                </td><?php } ?>
            </tr>
        {/mstrstock}
    <?php } else{
            echo "<tr>";
            echo "<td colspan='9' style='text-align:center;color:red;'>No Data To Display</td>";
            echo "</tr>";
    } ?>
    <?php if(!empty($message))?>{message}
</table>
<?php echo $links; ?>